package com.shaw.workrecord.controller;

import com.shaw.workrecord.entity.ResponseBean;
import com.shaw.workrecord.interceptor.PassToken;
import com.shaw.workrecord.pojo.request.LoginRequest;
import com.shaw.workrecord.pojo.response.LoginResponse;
import com.shaw.workrecord.service.ILoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jh.jiang
 * date 2022-08-13
 * description
 */
@Api(tags="登录模块")
@RestController
@Validated
public class LoginController {

    @Autowired
    private ILoginService loginService;

    @PassToken
    @ApiOperation(value = "登录")
    @PostMapping("/login")
    public ResponseBean<LoginResponse> login(@RequestBody LoginRequest request) {
        LoginResponse login = loginService.login(request);
        return ResponseBean.success(login);
    }
}
